<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>
<%@ taglib prefix="fns" uri="/WEB-INF/tlds/fns.tld"%>
<!DOCTYPE html>
<html>
<head>
		<title>站内信添加</title>
		<!-- 引入公用Js与Css -->
  		<%@include file="/view/common/resource.jsp" %>
	</head>
	<body>
		<div id="wrap">
			<div class="clearfix mt10 mr10 ml10">
				<form id="newsForm" class="form-horizontal" action="<%=basePath%>/business/message/messageSave" method="post">
					<input type="hidden" id="memberId" name="memberId" value="${memberId}">
					<input type="hidden" id="receiveId" name="receiveId" value="">
					<input type="hidden" id="status" name="status" value="">
					<dl class="ml10">
						<dd class="clearfix pt10">
							<label class="w80 mr10 pull-left text-right line-height30">标题:</label>
							<div class="w300 input-group input-group-sm">
								<input type="text" id="title" name="title" class="form-control" placeholder="请填写站内信标题(必填项)"/>
							</div>
						</dd>
						<dd class="clearfix pt10">
							<label class="w80 mr10 pull-left text-right line-height30">收信人:</label>
							<div class="w300 input-group input-group-sm">
								<input type="text" id="receiveName" name="receiveName" value="" readonly class="form-control" onclick="getMember()"/>
								<!-- <p class="pull-left text-center bg_blue radius5 pt5 mt5 pl5 pr5 pb5 ml10 mr10 font12"><a href="javascript:void(0);" ;" class="color_white">选择个人</a></p> -->
							</div>
						</dd>
						<dd class="clearfix pt10">
							<label class="w80 mr10 pull-left text-right line-height30">内容:</label>
							<div class="w300 input-group input-group-sm">
								<textarea rows="7" id="content" name="content" style="height: 128px; margin-top: 0px; margin-bottom: 0px;" class="form-control" placeholder="请填写站内信内容(必填项)"></textarea>
							</div>
						</dd>
						<dl>
							<dd class="clearfix pt10 pull-left">
								<p class="text-center  radius3 ml100 line-height30"><button type="button" onclick="save(0);" class="btn btn-default">保存</button></p>
							</dd>	            
							<dd class="clearfix pt10 pull-left">
								<button type="button" onclick="save(1);" class="ml100 btn btn-default">发送</button>
							</dd>
			            </dl>
					</dl>
				</form>
			</div>
		</div>
		<script type="text/javascript">
		/**
		 * 验证
		 */
		var validate = null;
		$(document).ready(function(){
			validate = $('#newsForm').validate({
				rules:{
					title:{
						required:true,
						maxlength:20
					},
					receiveName:{
						required:true
					},
					content:{
						required:true,
						maxlength:100
					}			
				},
				messages:{
					title:{
						required:"请填写标题",
						maxlength:"您输入20字符内的标题"
					},receiveName:{
						required:"请选择收件人"
					},
					content:{
						required:"请填写内容",
						maxlength:"您输入的内容过长，请控制在100字符内"
					}
				},
				errorPlacement: function(error, element) {
					layer.tips(error.text(), '#'+element.attr("name"), {
					  tips: [2, '#78BA32']
					});
				}
			});
		});
	    
		/**
		 * 获取系统用户
		 */
		function getMember(){
			var url = 'sysUsers';
			layer.open({
		      type: 2,
		      title: '指定个人',
		      shadeClose: true,
		      shade: false,
		      move: false,
		      maxmin: true, //开启最大化最小化按钮
		      area: ['550px', '400px'],
		      skin: 'layui-layer-rim', //加上边框
		      content: url
			});
		}

	   
    	/* 注册数据保存 */
	    function save(status) {
    		$("#status").val(status);
    		// 验证数据
	    	if (!validate.form()) {
	    		return false;
	    	}
    	    var actionurl=$('#newsForm').attr('action');//提交路径
    	    
    	    $("#newsForm").ajaxSubmit({
    	    	type:"post",
    	    	url:actionurl,
    	    	dataType: "json",
    	    	success:function(data){
   	   	        	// 成功后跳转首页
   	   	            layer.msg("提交成功", {icon: 6,time:1000}, function() {
   	   	            	var index = parent.layer.getFrameIndex(window.name); //获取窗口索引
   	   	            	parent.layer.close(index);
      	    		});
    	    	}
    	    }); 
	    }
    </script>
</body>
</html>
